﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace PhilWicklund.com.FacebookParts
{
    public class CommentsPart: System.Web.UI.WebControls.WebParts.WebPart
    {
        private Orientations orientation = Orientations.left;
        [System.Web.UI.WebControls.WebParts.WebBrowsable(true),
         System.Web.UI.WebControls.WebParts.WebDisplayName("Orientation"),
         System.Web.UI.WebControls.WebParts.WebDescription("Select the centering for the web part."),
         System.Web.UI.WebControls.WebParts.Personalizable(
         System.Web.UI.WebControls.WebParts.PersonalizationScope.User),
         System.ComponentModel.Category("Facebook Settings"),
         System.ComponentModel.DefaultValue(Orientations.left)
        ]
        public Orientations Orientation
        {
            get
            {
                return orientation;
            }
            set
            {
                orientation = value;
            }
        }

        protected override void CreateChildControls()
        {
            try
            {
                StringBuilder script = new StringBuilder();
                script.Append("<table style='padding:5px' width='100%'><tr><td width='100%'  align='" + Orientation.ToString() + "'><fb:comments></fb:comments></td></tr></table>");

                this.Controls.Add(new LiteralControl(script.ToString()));
            }
            catch (Exception e) { this.Controls.Add(new LiteralControl(e.Message)); }
        }
    }
}
